
const user = {
    state: () => ({
        username: '江子',
        age: 18
    }),
    mutations: {
        setUsername(state) {
            state.username = '江哥'
        },
        setAge(state) {
            state.age += 2
        },
        setAgeNum(state, num) {
            state.age += num
        }
    },
    actions: {
        asyncSetAge(content) {
            setTimeout(() => {
                console.log('setAge...');
                content.commit('setAge');
            }, 1000)
        },
        asyncSetAgeNum(content) {
            content.commit('setAgeNum', 5)
        }
    },
    getters: {
        descrption(state, getters, rootState) {
            return state.username + '年龄是' + state.age
        }
    },
    modules: {

    }
}
export default user